﻿using System.Linq;
using System.Text;
using System.Collections;
using RAP.Framework.Libary.Utils;
using RAP.Framework.Libary.DomTemplateBuilder.Element.ArrayListActions.Add;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;

namespace RAP.Framework.Libary.DomTemplateBuilder.Handler.ArrayListActions
{
	/// <summary>
	/// 数组动作的Handler
	/// </summary>
	public class ArrayListElementHandler : PropertyElementHandler
	{
		public new ArrayListAddAction Element
		{
			get
			{
				return base.Element as ArrayListAddAction;
			}
			set
			{
				base.Element = value;
			}
		}

		public override void DoRender ( StringBuilder writer,
			object rootParamObject,
			object parentParamObject,
			ITemplateRenderContext context )
		{
			var paramObject = this.GetParamObject ( rootParamObject, parentParamObject, context );
			var list = context.ToList( ArrayListActionHandler.ARRAY_LIST_OBJECT );
			if ( list != null )
			{
				var actionWriter = new StringBuilder ( );
				base.DoRender ( actionWriter, rootParamObject, paramObject, context );
				DoAction ( list, actionWriter );
			}
		}

		/// <summary>
		/// 对数组的操作动作
		/// </summary>
		/// <param name="dict"></param>
		/// <param name="writer"></param>
		public virtual void DoAction ( IList list, object data )
		{

		}
	}
}
